package com.bysj.controller;

import com.bysj.entity.Topic;
import com.bysj.entity.TopicReply;
import com.bysj.service.TopicReplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("topicReply")
public class TopicReplyController {
    @Autowired
    TopicReplyService topicReplyService;
    //插入评论
    @ResponseBody
    @RequestMapping("/addTopicReply")
    public String addTopic(@RequestBody TopicReply topicReply){
        topicReplyService.addTopicReply(topicReply);
        return "ok";
    }

    //查询当前贴子的所有评论
    @RequestMapping("/getTopicReplyById")
    public List<TopicReply> getTopicReplyById(Integer id){
        return topicReplyService.getTopicReplyById(id);
    }

    //根据id删除评论
    @RequestMapping("/deleteReplyById")
    public String deleteReplyById(Integer id){
        topicReplyService.deleteReplyById(id);
        return "success";
    }
}

